package com.tmeone.erpone.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tmeone.erpone.entity.JsonResult;
import com.tmeone.erpone.entity.TProductHandover;
import com.tmeone.erpone.service.IProductHandoverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ProductHandoverController {
    @Autowired
    private IProductHandoverService iProductHandoverService;

    @RequestMapping("/productHandover")
    public JsonResult productHandoverPage(@RequestParam(value = "current",required = false,defaultValue = "1")Integer current,
                                          @RequestParam(value = "pageSize",required = false,defaultValue = "5")Integer pageSize){
        Page<TProductHandover> page = new Page<>(current, pageSize);
        IPage<TProductHandover> tProductHandoverIPage = iProductHandoverService.selectProductHandover(page);
        return new JsonResult(1,tProductHandoverIPage);
    }
    @RequestMapping("/productHandover1")
    public JsonResult productHandoverPageById(@RequestParam(value = "current",required = false,defaultValue = "1")Integer current,
                                          @RequestParam(value = "pageSize",required = false,defaultValue = "5")Integer pageSize,
                                              String orderId){
        Page<TProductHandover> page = new Page<>(current, pageSize);
        IPage<TProductHandover> tProductHandoverIPage = iProductHandoverService.selectProductHandoverById(page,orderId);
        return new JsonResult(1,tProductHandoverIPage);
    }
    @DeleteMapping("/productHandover")
    public JsonResult productHandoverDelete(String [] arr){
        for (String s : arr) {
            iProductHandoverService.removeById(s);
        }
        return new JsonResult(1,null);
    }
}
